package com.dc.management.services;

import java.util.List;

import com.dc.management.dao.NewsDAO;
import com.dc.management.pojo.News;

/**
 * 
 */
public class NewsService {

	private NewsDAO dao;

	public NewsService() {
		dao = new NewsDAO();
	}
	
	public boolean publish(News news){
		return dao.insert(news);
		
	}
	
	public List<News> listNewsByPage(String pageNum, String pageSize, String publish_time){
		int pageNumInt =1 ;
		try{
			pageNumInt = Integer.parseInt(pageNum);
			if(pageNumInt <1){
				pageNumInt = 1;
			}
		}catch(Exception e){
			
		}
		
		int pageSizeInt = 10;
		try{
			pageSizeInt = Integer.parseInt(pageSize);
		}catch(Exception e){
			
		}
		
		int pageIndex = (pageNumInt-1)*pageSizeInt+1;
		
		return dao.listNewsByPageAndTime(pageIndex,pageSizeInt,publish_time);
	}

	public List<News> listNews() {
		return dao.listNews();
	}
	

}
